package uit.mmt02.activity;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

public class connectionManager 
{
	Context context;
	String tag = "connection Manager";
	public connectionManager(Context context)
	{
		Log.i(tag, "check connection");
		this.context = context;
	}
	
	public boolean checkConn() // kiem tra co ket noi internet hay khong
	{
		ConnectivityManager conMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo net_mobie =  conMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		NetworkInfo net_wifi = conMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		
		if (net_mobie.getState() == NetworkInfo.State.CONNECTED || net_wifi.getState() == NetworkInfo.State.CONNECTED )
			return true;
		else
			return false;
	}

}
